package com.ld.admin.util.daliySentence;

import java.util.LinkedHashMap;
import java.util.Map;

import com.ld.admin.util.daliySentence.impl.DaliySentenceDailywd;
import com.ld.admin.util.daliySentence.impl.DaliySentenceEudic;
import com.ld.admin.util.daliySentence.impl.DaliySentenceHitokoto;
import com.ld.admin.util.daliySentence.impl.DaliySentenceIciba;
import com.ld.admin.util.daliySentence.impl.DaliySentenceJinrishici;
import com.ld.admin.util.daliySentence.impl.DaliySentenceJuzikong;
import com.ld.admin.util.daliySentence.impl.DaliySentenceLovelive;
import com.ld.admin.util.daliySentence.impl.DaliySentenceMtime;
import com.ld.admin.util.daliySentence.impl.DaliySentenceOne;
import com.ld.admin.util.daliySentence.impl.DaliySentenceYiju;
import com.ld.shieldsb.common.core.ServiceFactory;

/**
 * 每日一句服务类享元工厂
 * 
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2020年7月22日 上午8:28:06
 *
 */
public class DaliySentenceServiceFactory extends ServiceFactory<DaliySentence> {
    public static final Map<String, String> KEYNAMES = new LinkedHashMap<>();

    static {
        // 注意工厂类不要一开始就注册对象，否则可能缺少必要的jar包不能实例化报错，应该注册类
        registerServiceClass(DaliySentenceOne.KEY, DaliySentenceOne.NAME, DaliySentenceOne.class); // One
        registerServiceClass(DaliySentenceIciba.KEY, DaliySentenceIciba.NAME, DaliySentenceIciba.class); // 爱词霸
        registerServiceClass(DaliySentenceEudic.KEY, DaliySentenceEudic.NAME, DaliySentenceEudic.class); // 欧陆词典
        registerServiceClass(DaliySentenceJinrishici.KEY, DaliySentenceJinrishici.NAME, DaliySentenceJinrishici.class); // 今日诗词
        registerServiceClass(DaliySentenceMtime.KEY, DaliySentenceMtime.NAME, DaliySentenceMtime.class); // 时光网
        registerServiceClass(DaliySentenceHitokoto.KEY, DaliySentenceHitokoto.NAME, DaliySentenceHitokoto.class); // 一言
        registerServiceClass(DaliySentenceDailywd.KEY, DaliySentenceDailywd.NAME, DaliySentenceDailywd.class); // 木芽一言
        registerServiceClass(DaliySentenceLovelive.KEY, DaliySentenceLovelive.NAME, DaliySentenceLovelive.class); // 土味情话
        registerServiceClass(DaliySentenceJuzikong.KEY, DaliySentenceJuzikong.NAME, DaliySentenceJuzikong.class); // 句子控
        registerServiceClass(DaliySentenceYiju.KEY, DaliySentenceYiju.NAME, DaliySentenceYiju.class); // 一句
    }

    public static void registerServiceClass(String key, String name, Class<? extends DaliySentence> clz) {
        KEYNAMES.put(key, name);
        getInstance().registerServiceClass(key, clz);
    }

    public static ServiceFactory<DaliySentence> getInstance() {
        return getInstance(DaliySentenceServiceFactory.class);
    }

}
